package com.sihai.tmall.adminhome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sihai.tmall.adminhome.service.AdminHomeService;
import com.tamll.bean.OrderGroup;
import com.tamll.bean.ProductOrder;
import com.tmall.mapper.OrderGroupMapper;
import com.tmall.mapper.ProductOrderMapper;
import com.tmall.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminHomeServiceImpl implements AdminHomeService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private OrderGroupMapper orderGroupMapper;
    @Autowired
    private ProductOrderMapper productOrderMapper;
    @Override
    public Long onSaleProductTotal(Byte productOrderStatus) {
        QueryWrapper<ProductOrder> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("productOrderStatus",productOrderStatus);
        Long count = productOrderMapper.selectCount(queryWrapper);
        return count;
    }

    @Override
    public Long userTotal() {
        return userMapper.selectCount(null);
    }

    @Override
    public Long productOrderTotal(Integer productOrderCount) {
        QueryWrapper<OrderGroup> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("productOrderCount",productOrderCount);
        Long count = orderGroupMapper.selectCount(queryWrapper);
        return count;
    }
}
